﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class Poolable : MonoBehaviour 
{
	protected Pooler myPooler;
	protected Stack<GameObject> myStack;
	public float timer = 0.0f;
	public float lifeTime = 10.0f;

	protected virtual void Update()
	{
		timer += Time.deltaTime;
		if(timer >= lifeTime)
		{
			timer = 0.0f;
			myPooler.AddToPool(gameObject, myStack);
		}
	}

	public void SetPooler(Pooler pool, Stack<GameObject> stack)
	{
		myPooler = pool;
		myStack = stack;
	}
}
